# 1. 列表套字典
users = [
    {'name': 'Zoe', 'password': '123456', 'not_allowed': False},
    {'name': 'Furse', 'password': '89023', 'not_allowed': False},
    {'name': 'Crucial', 'password': '0000', 'not_allowed': True},
]

flag = False
for j in range(3):
    name = input("please input your name: ")
    password = input("please input your password: ")
    for i in users:
        if name == i['name']:
            if password == i['password']:
                if i['not_allowed'] == False:
                    print('login successfully')
                    flag = True
                else:
                    print('your account is invalid, please contact us')
            else:
                print('your password error, please try again')
            break
    else:
        print('your name error, please try again')

    if flag:
        break

# 2. 字典套字典
users1 = {
    'Zoe': {'name': 'Zoe', 'password': '123456', 'not_allowed': False},
    'Furse': {'name': 'Furse', 'password': '789', 'not_allowed': False},
    'Jack': {'name': 'Jack', 'password': '000000', 'not_allowed': True},
}

for i in range(3):
    name = input('please input your name: ')
    password = input('please input your password: ')
    if name in users1 and password == users1[name]['password'] and users1[name]['not_allowed'] == False:
        print('login successfully')
        break
    elif name in users1 and password != users1[name]['password']:
        print('your password error, please try again')
    elif name in users1 and not users1[name]['not_allowed']:
        print('your account is invalid, please contact us')
    else:
        print('your name error, please try again')

